<template>
  <div class="app-container01">
    <div class="filter-container bor-container">
      <el-form size="mini" :inline="true">
        <el-form-item class="input_co999"   label="ID号">
          <el-input v-model="formInline.playerNo" placeholder=""></el-input>
        </el-form-item>
        <el-form-item class="input_co999"   label="成员昵称">
          <el-input v-model="formInline.nickname" placeholder=""></el-input>
        </el-form-item>
        <el-button size="mini" @click="query()" icon="el-icon-search">查询</el-button>
      </el-form>
    </div>
    <div v-show="showList">
      <div class="filter-container btn-right">
        <!--<el-button size="mini"  type="primary"  icon="el-icon-plus"  @click="dialog.gameStatus = true">添加游戏</el-button>-->
      </div>
      <el-table v-loading="loading" border :data="tableData">
        <el-table-column prop="name" label="成员">
          <template scope="scope">
            {{scope.row.name}}&nbsp;ID:{{scope.row.playerNo}}
          </template>
        </el-table-column>
        <el-table-column prop="createTime" label="加入时间">
      </el-table-column>
        <el-table-column prop="updateTime" label="最后上线时间">
        </el-table-column>
        <el-table-column prop="value" label="总收益">
        </el-table-column>
        <!--<el-table-column prop="createTime" label="订单总收益">
        </el-table-column>
        <el-table-column prop="role_name" label="礼物总收益">
        </el-table-column>-->
        <el-table-column label="操作"  align="center">
          <template slot-scope="scope">
            <el-button  size="mini" type="warning" @click="openEdit(scope.row)"  >查看</el-button>
           <!-- <el-button v-if="scope.row.statustype == 1" size="mini" type="warning"   >下架</el-button>
            <el-button v-else-if="scope.row.statustype == 0" size="mini" type="warning"   >上架</el-button>-->
            <el-button  size="mini" type="warning"  @click="openPresetEdit(scope.row)" >踢出</el-button>
           <!-- <el-button  size="mini" type="danger" @click="deleteUser(scope.row)"  >刪除</el-button>-->
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        class="pagination-right"
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="formInline.page"
        :page-sizes="[10]"
        :page-size="formInline.pagenum"
        layout="total, sizes, prev, pager, next, jumper"
        :total="formInline.total">
      </el-pagination>
      <game-edit
        v-if="dialog.gameStatus"
        :dialog_="dialog.gameStatus"
        :name="dialog.name"
        :playerNo="dialog.playerNo"
        @close="closeGame()"
        @success="success()"
      >
      </game-edit>
      <preset-room
        v-if="dialog.presetStatus"
        :dialog_="dialog.presetStatus"
        :name="dialog.name"
        :id="dialog.id"
        @close="closePreset()"
        @success="success()"
      >
      </preset-room>
    </div>
  </div>
</template>
<script>
  import { mapGetters } from 'vuex'
  import { getUnionPeopleListAPI, getKickOutAPI} from '@/api/user'
  import GameEdit from './components/GameEdit'
  import PresetRoom from './components/PresetRoom'
  export default {
    // 角色管理
    name: 'GameSystem',
    components: {
      PresetRoom,
      GameEdit
    },
    data() {
      return {
        activeName: 'first',
        showList: true,
        showRole:false,
        formInline: {
          playerNo: '',
          nickname:'',
          pageSize: 10,
          pageNum: 1,
          total: 0
        },
        dialog: {
          gameStatus: false,
          presetStatus: false,
          name: null,
          playerNo:'',
          id:''
        },
        loading: false,
        tableData: [],
      }
    },
    computed: {
      ...mapGetters([
        'buttons',
      ])
    },
    methods: {
      // 打开编辑页面
      openEdit(obj) {
       // this.dialog.name = obj.admin_name
        this.dialog.playerNo = obj.playerNo
        this.dialog.gameStatus = true
        this.dialog.name = obj.playerNo
      },
      // 点击查询事件
      query() {
        this.formInline.pageNum = 1
        this.getGameList()
      },
      openPresetEdit(obj) {
          this.$prompt('请输入踢出理由(踢出成员为)'+obj.playerNo, '', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            inputErrorMessage: '字数不能多于20个',
            inputType:'textarea',
            inputPattern: /^\S{1,20}$/
          }).then(({ value }) => {
            this.getKickOut(obj.playerNo)
          }).catch(() => {
            /*this.$message({
              type: 'info',
              message: '取消输入'
            });*/
          });
      },
      // 删除
      deleteUser(obj) {
        this.$confirm('是否删除该管理员账号，删除后该账号无法登录后台系统', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          let param = {
            account:obj.admin_name,
            operator:'admin'
          }
          // deleteAPI(param).then(res => {
          //   if (res.code === 0) {
          //     this.$message({
          //       type: 'success',
          //       message: '删除成功!'
          //     });
          //     this.getRoleList()
          //   } else {
          //     this.$message.error('删除失败，请稍后重试')
          //   }
          // })
        }).catch(() => {
          // this.$message({
          //   type: 'info',
          //   message: '已取消删除'
          // });
        });
      },
      // 操作成功更新列表
      success() {
        this.getGameList()
      },
      closeGame() {
        this.dialog.gameStatus = false
        this.dialog.name = null
      },
      closePreset() {
        this.dialog.presetStatus = false
        this.dialog.name = null
      },
      handleClick(tab, event) {
        if (tab.name === 'first') {
          this.showList = true;
          this.showRole = false;
        } else {
          this.showList = false;
          this.showRole = true;
        }
        console.log(tab, event);
      },
      // pageSize发生改变触发
      handleSizeChange(val) {
        this.formInline.pagenum = 10
        this.formInline.page = val
        this.getGameList()
      },
      // pageNum 发生改变触发
      handleCurrentChange(val) {
        this.formInline.pageNum = val
        this.getGameList()
      },
      getGameList() {
        this.loading = true
        getUnionPeopleListAPI(this.formInline).then(res => {
          this.loading = false
          if (res.rtnInfo.code === 0) {
            this.tableData = res.rtnInfo.data.list
            this.formInline.total= res.rtnInfo.data.total;
          } else {
            this.$message.error(res.message)
          }
        })
      },
      // 踢出公会
      getKickOut(playerNo) {
        this.loading = true
        let paramater = {
          playerNo:playerNo
        }
        getKickOutAPI(paramater).then(res => {
          this.loading = false
          if (res.rtnInfo.code === 0) {
            this.getGameList()
            this.$message.success(res.rtnInfo.msg)
          } else {
            this.$message.error(res.rtnInfo.msg)
          }
        })
      }
    },
    mounted() {
      this.getGameList()
    }
  }
</script>
<style>

  /* .cy_game {
    width: 861px;
    height: 308px;
    margin-left: 68px;
  } */


  /*span.xiadandan {*/
  /*  display: inline-block;*/
  /*  width: 80px;*/
  /*  height: 20px;*/
  /*  margin-left: -647px;*/
  /*  margin-top: 37px;*/
  /*}*/
  .el-dialog {
    width: 1027px !important;
  }
  .app-container01 {
    padding: 20px;
  }
  /*.el-select {*/
  /*  display: inline-block;*/
  /*  position: relative;*/
  /*  margin-left: -38px;*/
  /*}*/
  span.xiadandan {
    display: inline-block;
    width: 80px;
    height: 20px;
    margin-left: -721px;
  }
  span.el-pagination__total {
    margin-right: 29px;
    display: inline-block;
  }
  span.pie_tutu {
    display: inline-block;
    width: 300px;
    height: 300px;
    /*background: palevioletred;*/
    margin-left: 142px;
    margin-top: 51px;
  }
</style>

